package org.wiztools.oembed;

import java.util.Collections;
import java.util.Map;
import java.util.LinkedHashMap;
import static org.wiztools.oembed.OEmbedType.*;

/**
 * The default implementation of <code>org.wiztools.oembed.OEmbedResponse</code>.
 * @author subhash
 */
public class OEmbedResponseBean implements OEmbedResponse {
    private Map<String, String> map = new LinkedHashMap<>();
    private OEmbedVersion version;
    private OEmbedType type;
    private int width;
    private int height;
    private String title;
    private String url;
    private String html;
    private String author_name;
    private String author_url;
    private String provider_name;
    private String provider_url;
    private int cache_age;
    private String thumbnail_url;
    private int thumbnail_width;
    private int thumbnail_height;
    
    public void addElement(String key, String value) {
        map.put(key, value);
    }
    
    public Map<String, String> getElements() {
        return Collections.unmodifiableMap(map);
    }

    public String getAuthor_name() {
        return author_name;
    }

    public void setAuthor_name(String author_name) {
        this.author_name = author_name;
    }

    public String getAuthor_url() {
        return author_url;
    }

    public void setAuthor_url(String author_url) {
        this.author_url = author_url;
    }

    public int getCache_age() {
        return cache_age;
    }

    public void setCache_age(int cache_age) {
        this.cache_age = cache_age;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public String getProvider_name() {
        return provider_name;
    }

    public void setProvider_name(String provider_name) {
        this.provider_name = provider_name;
    }

    public String getProvider_url() {
        return provider_url;
    }

    public void setProvider_url(String provider_url) {
        this.provider_url = provider_url;
    }

    public int getThumbnail_height() {
        return thumbnail_height;
    }

    public void setThumbnail_height(int thumbnail_height) {
        this.thumbnail_height = thumbnail_height;
    }

    public String getThumbnail_url() {
        return thumbnail_url;
    }

    public void setThumbnail_url(String thumbnail_url) {
        this.thumbnail_url = thumbnail_url;
    }

    public int getThumbnail_width() {
        return thumbnail_width;
    }

    public void setThumbnail_width(int thumbnail_width) {
        this.thumbnail_width = thumbnail_width;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public OEmbedType getType() {
        return type;
    }

    public void setType(OEmbedType type) {
        this.type = type;
    }
    
    public boolean isPhoto() {
        return (type == PHOTO)? true: false;
    }
    public boolean isVideo() {
        return (type == VIDEO)? true: false;
    }
    public boolean isLink() {
        return (type == LINK)? true: false;
    }
    public boolean isRich() {
        return (type == RICH)? true: false;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
    
    public String getHtml() {
        return html;
    }
    
    public void setHtml(String html) {
        this.html = html;
    }

    public OEmbedVersion getVersion() {
        return version;
    }

    public void setVersion(OEmbedVersion version) {
        this.version = version;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
    
    @Override
    public String toString() {
        return map.toString();
    }
}
